namespace JPW.OnlinePaperSubmissionSystem.Migrations
{
    using System;
    using System.Collections.Generic;
    using System.Data.Entity.Infrastructure.Annotations;
    using System.Data.Entity.Migrations;
    
    public partial class Addes_All_Tables : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.AnnouncementContacts",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        ReceiveUserId = c.Long(),
                        SendUserId = c.Long(),
                        AnnouncementId = c.Long(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Announcements", t => t.AnnouncementId)
                .ForeignKey("dbo.AbpUsers", t => t.ReceiveUserId)
                .ForeignKey("dbo.AbpUsers", t => t.SendUserId)
                .Index(t => t.ReceiveUserId)
                .Index(t => t.SendUserId)
                .Index(t => t.AnnouncementId);
            
            CreateTable(
                "dbo.Announcements",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        Title = c.String(),
                        Content = c.String(),
                        CreatTime = c.DateTime(),
                        status = c.Int(nullable: false),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_Announcement_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Audits",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        UserId = c.Long(),
                        AuditContent = c.String(),
                        AuditStatuId = c.Long(),
                        AuditTime = c.DateTime(),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_Audit_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.ParameterTypes", t => t.AuditStatuId)
                .ForeignKey("dbo.AbpUsers", t => t.UserId)
                .Index(t => t.UserId)
                .Index(t => t.AuditStatuId);
            
            CreateTable(
                "dbo.ParameterTypes",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        Name = c.String(),
                        Code = c.String(),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Filess",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        UserId = c.Long(),
                        Name = c.String(),
                        Path = c.String(),
                        CreatTime = c.DateTime(),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_Files_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.AbpUsers", t => t.UserId)
                .Index(t => t.UserId);
            
            CreateTable(
                "dbo.InstructionsFiless",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        InstructionsId = c.Long(),
                        FileId = c.Long(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Filess", t => t.FileId)
                .ForeignKey("dbo.Instructionss", t => t.InstructionsId)
                .Index(t => t.InstructionsId)
                .Index(t => t.FileId);
            
            CreateTable(
                "dbo.Instructionss",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        Name = c.String(),
                        Content = c.String(),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_Instructions_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.ManuscriptCheckeds",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        AuditId = c.Long(),
                        ManuscriptId = c.Long(),
                        CurUserID = c.Long(),
                        NextUserID = c.Long(),
                        IsFinish = c.Boolean(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Audits", t => t.AuditId)
                .ForeignKey("dbo.AbpUsers", t => t.CurUserID)
                .ForeignKey("dbo.Manuscripts", t => t.ManuscriptId)
                .ForeignKey("dbo.AbpUsers", t => t.NextUserID)
                .Index(t => t.AuditId)
                .Index(t => t.ManuscriptId)
                .Index(t => t.CurUserID)
                .Index(t => t.NextUserID);
            
            CreateTable(
                "dbo.Manuscripts",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        ManuscriptStatusID = c.Long(),
                        UserId = c.Long(),
                        LongTitle = c.String(),
                        ShortTitle = c.String(),
                        Summary = c.String(),
                        KeyWord = c.String(),
                        ManuscriptDescription = c.String(),
                        ManuscriptContent = c.String(),
                        ContributeTime = c.DateTime(),
                        ManuscriptTypeID = c.Long(),
                        ColumnTypeID = c.Long(),
                        IsDeleted = c.Boolean(nullable: false),
                        DeleterUserId = c.Long(),
                        DeletionTime = c.DateTime(),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Long(),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Long(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_Manuscript_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.ParameterTypes", t => t.ColumnTypeID)
                .ForeignKey("dbo.ManuscriptStatuss", t => t.ManuscriptStatusID)
                .ForeignKey("dbo.ParameterTypes", t => t.ManuscriptTypeID)
                .ForeignKey("dbo.AbpUsers", t => t.UserId)
                .Index(t => t.ManuscriptStatusID)
                .Index(t => t.UserId)
                .Index(t => t.ManuscriptTypeID)
                .Index(t => t.ColumnTypeID);
            
            CreateTable(
                "dbo.ManuscriptStatuss",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        ManuscriptStatusName = c.String(),
                        Order = c.Int(),
                        Code = c.String(),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.WriterInformations",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        UserId = c.Long(),
                        Sex = c.String(),
                        IDCard = c.String(),
                        Post = c.String(),
                        Telephone = c.String(),
                        Unit = c.String(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.AbpUsers", t => t.UserId)
                .Index(t => t.UserId);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.WriterInformations", "UserId", "dbo.AbpUsers");
            DropForeignKey("dbo.ManuscriptCheckeds", "NextUserID", "dbo.AbpUsers");
            DropForeignKey("dbo.ManuscriptCheckeds", "ManuscriptId", "dbo.Manuscripts");
            DropForeignKey("dbo.Manuscripts", "UserId", "dbo.AbpUsers");
            DropForeignKey("dbo.Manuscripts", "ManuscriptTypeID", "dbo.ParameterTypes");
            DropForeignKey("dbo.Manuscripts", "ManuscriptStatusID", "dbo.ManuscriptStatuss");
            DropForeignKey("dbo.Manuscripts", "ColumnTypeID", "dbo.ParameterTypes");
            DropForeignKey("dbo.ManuscriptCheckeds", "CurUserID", "dbo.AbpUsers");
            DropForeignKey("dbo.ManuscriptCheckeds", "AuditId", "dbo.Audits");
            DropForeignKey("dbo.InstructionsFiless", "InstructionsId", "dbo.Instructionss");
            DropForeignKey("dbo.InstructionsFiless", "FileId", "dbo.Filess");
            DropForeignKey("dbo.Filess", "UserId", "dbo.AbpUsers");
            DropForeignKey("dbo.Audits", "UserId", "dbo.AbpUsers");
            DropForeignKey("dbo.Audits", "AuditStatuId", "dbo.ParameterTypes");
            DropForeignKey("dbo.AnnouncementContacts", "SendUserId", "dbo.AbpUsers");
            DropForeignKey("dbo.AnnouncementContacts", "ReceiveUserId", "dbo.AbpUsers");
            DropForeignKey("dbo.AnnouncementContacts", "AnnouncementId", "dbo.Announcements");
            DropIndex("dbo.WriterInformations", new[] { "UserId" });
            DropIndex("dbo.Manuscripts", new[] { "ColumnTypeID" });
            DropIndex("dbo.Manuscripts", new[] { "ManuscriptTypeID" });
            DropIndex("dbo.Manuscripts", new[] { "UserId" });
            DropIndex("dbo.Manuscripts", new[] { "ManuscriptStatusID" });
            DropIndex("dbo.ManuscriptCheckeds", new[] { "NextUserID" });
            DropIndex("dbo.ManuscriptCheckeds", new[] { "CurUserID" });
            DropIndex("dbo.ManuscriptCheckeds", new[] { "ManuscriptId" });
            DropIndex("dbo.ManuscriptCheckeds", new[] { "AuditId" });
            DropIndex("dbo.InstructionsFiless", new[] { "FileId" });
            DropIndex("dbo.InstructionsFiless", new[] { "InstructionsId" });
            DropIndex("dbo.Filess", new[] { "UserId" });
            DropIndex("dbo.Audits", new[] { "AuditStatuId" });
            DropIndex("dbo.Audits", new[] { "UserId" });
            DropIndex("dbo.AnnouncementContacts", new[] { "AnnouncementId" });
            DropIndex("dbo.AnnouncementContacts", new[] { "SendUserId" });
            DropIndex("dbo.AnnouncementContacts", new[] { "ReceiveUserId" });
            DropTable("dbo.WriterInformations");
            DropTable("dbo.ManuscriptStatuss");
            DropTable("dbo.Manuscripts",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_Manuscript_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.ManuscriptCheckeds");
            DropTable("dbo.Instructionss",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_Instructions_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.InstructionsFiless");
            DropTable("dbo.Filess",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_Files_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.ParameterTypes");
            DropTable("dbo.Audits",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_Audit_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.Announcements",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_Announcement_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.AnnouncementContacts");
        }
    }
}
